/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.entidade.fermojupi;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;

/**
 *
 * @author roniere
 */
@Entity
public class EmolumentoItem implements Serializable{
    
    @Id
    @SequenceGenerator(name = "seq_emolumentoItem", sequenceName = "seq_emolumentoItem", allocationSize=1 )
    @GeneratedValue(generator = "seq_emolumentoItem", strategy = GenerationType.SEQUENCE)
    private int id;
    
    @OneToOne
    private Emolumento emol;
    
       
    @Column(scale= 2, precision=19)
    @DecimalMin( value = "0.00", message="Erro Deci val Ini" )
    private BigDecimal valInicial;
    
    @Column(scale= 2, precision=19)
    @DecimalMin( value = "0.00", message="Erro Deci val Ini"  )
    private BigDecimal valFinal;
    
    @Column(scale= 2, precision=19)
    @DecimalMin( value = "0.00", message="Erro Deci val Ini"  )
    private BigDecimal cartorio;
    
    @Column(scale= 2, precision=19)
    @DecimalMin( value = "0.00", message="Erro Deci val Ini"  )
    private BigDecimal fermojupi;
    
    @Column(scale= 2, precision=19)
    @DecimalMin( value = "0.00", message="Erro Deci val Ini"  )
    private BigDecimal valor;
    
    @Column
    private boolean oab;
    
    @Column
    private boolean status;
    
    @OneToOne(fetch=FetchType.EAGER)
    private AtoItem atoItem;

    public EmolumentoItem() {
        this.status = true;
    }

    public EmolumentoItem( BigDecimal valInicial) {
        this.status = true;
        this.valInicial = valInicial;
    }

    
    public AtoItem getAtoItem() {
        return atoItem;
    }

    public void setAtoItem(AtoItem atoItem) {
        this.atoItem = atoItem;
    }

    public BigDecimal getCartorio() {
        return cartorio;
    }

    public void setCartorio(BigDecimal cartorio) {
        this.cartorio = cartorio;
    }

    public Emolumento getEmol() {
        return emol;
    }

    public void setEmol(Emolumento emol) {
        this.emol = emol;
    }

    public BigDecimal getFermojupi() {
        return fermojupi;
    }

    public void setFermojupi(BigDecimal fermojupi) {
        this.fermojupi = fermojupi;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public boolean isOab() {
        return oab;
    }

    public void setOab(boolean oab) {
        this.oab = oab;
    }

    public BigDecimal getValFinal() {
        return valFinal;
    }

    public void setValFinal(BigDecimal valFinal) {
        if(valFinal == null){
            this.valFinal = BigDecimal.ZERO;
        }
        this.valFinal = valFinal;
    }

    public BigDecimal getValInicial() {
        return valInicial;
    }

    public void setValInicial(BigDecimal valInicial) {
        if(valInicial == null){
            this.valInicial = BigDecimal.ZERO;
        }else{
            this.valInicial = valInicial;
        }
    }

    public BigDecimal getValor() {
        return valor;
    }

    public void setValor(BigDecimal valor) {
        this.valor = valor;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }
    
    

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final EmolumentoItem other = (EmolumentoItem) obj;
        if (this.id != other.id) {
            return false;
        }
        if (this.emol != other.emol && (this.emol == null || !this.emol.equals(other.emol))) {
            return false;
        }
        if (this.valInicial != other.valInicial && (this.valInicial == null || !this.valInicial.equals(other.valInicial))) {
            return false;
        }
        if (this.valFinal != other.valFinal && (this.valFinal == null || !this.valFinal.equals(other.valFinal))) {
            return false;
        }
        if (this.cartorio != other.cartorio && (this.cartorio == null || !this.cartorio.equals(other.cartorio))) {
            return false;
        }
        if (this.fermojupi != other.fermojupi && (this.fermojupi == null || !this.fermojupi.equals(other.fermojupi))) {
            return false;
        }
        if (this.valor != other.valor && (this.valor == null || !this.valor.equals(other.valor))) {
            return false;
        }
        if (this.oab != other.oab) {
            return false;
        }
        if (this.atoItem != other.atoItem && (this.atoItem == null || !this.atoItem.equals(other.atoItem))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 53 * hash + this.id;
        hash = 53 * hash + (this.emol != null ? this.emol.hashCode() : 0);
        hash = 53 * hash + (this.valInicial != null ? this.valInicial.hashCode() : 0);
        hash = 53 * hash + (this.valFinal != null ? this.valFinal.hashCode() : 0);
        hash = 53 * hash + (this.cartorio != null ? this.cartorio.hashCode() : 0);
        hash = 53 * hash + (this.fermojupi != null ? this.fermojupi.hashCode() : 0);
        hash = 53 * hash + (this.valor != null ? this.valor.hashCode() : 0);
        hash = 53 * hash + (this.oab ? 1 : 0);
        hash = 53 * hash + (this.atoItem != null ? this.atoItem.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "EmolumentoItem{" + "emol=" + emol + ", valInicial=" + valInicial + ", valFinal=" + valFinal + ", cartorio=" + cartorio + ", fermojupi=" + fermojupi + ", valor=" + valor + ", oab=" + oab + ", atoItem=" + atoItem + '}';
    }
    
}
